#pragma once
#include "BRTree.h"

using namespace std;

//void PrintBRTree(const BRTree<int, int>& tree) {
//	for (auto e : tree) {
//
//		cout << e.first << " " << e.second << endl;
//	}
//	cout << endl;
//}

void BRTreeTest01() {
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14,16, 3, 7, 11, 9, 26, 18, 14, 15 };
	// {16, 3, 7, 11, 9, 26, 18, 14, 15}
	BRTree<int, int> tree;

	for (auto e : a) {
		
		tree.insert(make_pair(e, e));
	}
	tree.InOrder();
	cout << tree.isBalance() << endl;
}

void BRTreeTest02() {
	const int N = 1000000;
	vector<int> v;
	v.reserve(N);
	srand(time(0));
	for (int i = 0; i < N; i++) {
		v.push_back(rand() + 1);
	}
	size_t begin1 = clock();
	BRTree<int, int> tree;
	for (auto e : v)
		tree.insert({ e, e });
	size_t end1 = clock();
	cout << "insert" << end1 - begin1 << endl;

	cout << tree.isBalance() << endl;

}

void BRTreeTest03() {
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14,16, 3, 7, 11, 9, 26, 18, 14, 15 };
	BRTree<int, int> tree;
	for (auto e : a) 
		tree.insert(make_pair(e, e));
	
	/*auto it = tree.begin();
	while (it != tree.end()) {
		cout << it->first << ":" << it->second << endl;
		++it;
	}*/
	for (auto e : tree) {
		cout << e.first << " " << e.second << endl;
	}
	cout << endl;
	/*PrintBRTree(tree);*/

}

int main() {
	//BRTreeTest02();
	BRTreeTest03();
	//BRTreeTest01();
	return 0;
}
